package com.example.webchar.webchar.mapper.master;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.webchar.webchar.pojo.Novel;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: wechat-web-is-my
 * @description
 * @author: 郭逍
 * @create: 2021/8/21 10:57
 **/
@Mapper
@Service
public interface NovelMaster extends BaseMapper<Novel> {
    /**
     * 往小说的主表中批量插
     *
     * @param list
     */
    @Insert({"<script>insert into novel (name,update_location,type,url,score,brief_introduction,novel_name) values " +
            "<foreach collection=\"list\" item=\"item\" index=\"index\"  separator=\",\"> " +
            "(#{item.name},#{item.updateLocation},#{item.type},#{item.url},#{item.score},#{item.briefIntroduction},#{item.novelName})" +
            "</foreach></script>"})
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insNovelList(@Param("list") List<Novel> list);

    /**
     * 根据id删除小说主表中的小说信息
     *
     * @param id
     */
    @Delete("Delete from novel where id=#{id}")
    void deleteNovelById(@Param("id") Integer id);

}
